/**
 * 
 */
package com.hfjyz.exam.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.hfjyz.exam.command.LoginCommand;

/**
 *
 */
public class LoginValidator implements Validator {

	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	public boolean supports(Class clazz) {
		return clazz.isAssignableFrom(LoginCommand.class);
	}

	@Override
	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username",
				"error.login.username", "please input user name.");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password",
				"error.login.password", "please input password.");
	}

}
